<?php

$flag = true;

$loginpath = templet('find_password', 'index');

if (file_exists($loginpath)) {
    include $loginpath;
    $flag = false;
}


if ($flag) {

?>
    <style>
        body {
        <?php $item = tpl_get("基本设置");?> background: <?php echo $item[0]['color']?> !important;
        }
    </style>

    <link href="<?php echo SHOP_TEMPLATES_URL;?>/css/home_login.css" rel="stylesheet" type="text/css">
    <link href="<?php echo SHOP_TEMPLATES_URL;?>/css/base.css" rel="stylesheet" type="text/css">
    <link href="<?php echo SHOP_TEMPLATES_URL;?>/css/home_header.css" rel="stylesheet" type="text/css">
    <link href="<?php echo SHOP_TEMPLATES_URL;?>/css/member_login.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="/shop/templates/mln/font/css/font-awesome.css">
    <script src="/data/resource/layer/layer.js"></script>

    <style type="text/css">
        .public-top-layout, .head-app, .head-search-bar, .head-user-menu, .public-nav-layout, .nch-breadcrumb-layout, #faq {
            display: none !important;
        }
        .public-head-layout {
            margin: 10px auto -10px auto;
        }
        .wrapper {
            width: 1000px;
        }
        body #footer {
            border-top: none !important;
            padding-top: 30px;
        }
        .nc-login-title,.nc-login-content{
            background:#fff !important;
            border:0;
        }
        .nc-login-bottom{
            background:none;
        }

        #footer{
            position: fixed;
            bottom: 20px;
            left: 0;
            width: 100%;
            text-align: center;
        }
        html{
            height: 100%;
            overflow: hidden;
        }
    </style>

    <link rel="stylesheet" href="/packages/resource/pintuer/pintuer.css">

    <style>
        form .label{
            width: 25% !important;
        }
        form .field{
            width: 75% !important;
        }
    </style>
    <table style="position: fixed;left: 0;top: 0;width: 100%;height: 100%;text-align: center;">
        <tr>
            <td>
                <div class="pintuer" style="width: 600px;background: #fff;margin: 0 auto;box-shadow: 2px 2px 4px rgba(0,0,0,.5);border-radius : 5px">
                    <div class="text-left padding-big" >
                        <h1>
                            忘记密码
                        </h1>
                    </div>
                    <form id="find_password_form" action="<?php echo SHOP_SITE_URL;?>/index.php?act=login&op=find_password" method="post" class="form-x padding margin-big-top" style="max-width:400px;margin: 0 auto;">
                        <div class="form-group">
                            <div class="label">
                                手机号码：
                            </div>
                            <div class="field">
                                <input type="text" name="mobile" class="input">
                            </div>

                        </div>
                        <div class="form-group margin-top">
                            <div class="label">
                                校验码：
                            </div>
                            <div class="field">
                                <div class="input-group">
                                    <input type="text" name="code" class="input">

                                    <span class="addon" id="get_code" style="cursor: pointer;">
                                        发送短信
                                    </span>
                                </div>

                            </div>
                        </div>
                        <div class="form-group margin-top">
                            <div class="label">
                                新密码：
                            </div>
                            <div class="field">
                                <input type="text" name="password" class="input">

                            </div>
                        </div>
                        <div class="form-group margin-top">
                            <div class="label">
                                确认新密码：
                            </div>
                            <div class="field">
                                <input type="text" name="confirm_password" class="input">
                            </div>
                        </div>

                        <div class="text-center margin-big-top margin-big-bottom">
                            <button class="button bg-blue" id="submit">
                                提交
                            </button>
                        </div>


                    </form>
                </div>
            </td>
        </tr>
    </table>
    <script>
        $(function(){
            $('#get_code').click(function(){
                if($('input[name="mobile"]').val()==""){
                    layer.msg("请输入手机号");
                    return false;
                }
                var mobile = $('input[name="mobile"]').val();
                $.ajax({
                    url:"/shop/index.php?act=seccode&op=mobile_send_message",
                    type:"GET",
                    data:{mobile:mobile},
                    success:function(result){
                        if(result==0){
                            layer.msg("验证码发送成功");
                        }
                        else{
                            layer.msg("验证码发送失败");
                        }
                    }
                });
            });


            $('#Submit').click(function(){
                if($('input[name="mobile"]').val()==""){
                    layer.msg("请输入手机号");
                    return false;
                }
                if($('input[name="code"]').val()==""){
                    layer.msg("请输入验证码");
                    return false;
                }
                if($('input[name="password"]').val()==""){
                    layer.msg("请输入新密码");
                    return false;
                }
                if($('input[name="confirm_password"]').val()==""){
                    layer.msg("请确认新密码");
                    return false;
                }
                if($('input[name="password"]').val() != $('input[name="confirm_password"]').val()){
                    layer.msg("两次密码输入不一致");
                    return false;
                }
                $('#find_password_form').submit();
            });

            // $('#find_password_form').validate({
            //     errorPlacement: function(error, element){
            //         var error_td = element.parent('dd');
            //         error_td.find('label').hide();
            //         error_td.append(error);
            //     },
            //     rules : {
            //         username : {
            //             required : true
            //         },
            //         email : {
            //             required : true,
            //             email : true
            //         }
            //         // ,
            //         // captcha : {
            //         //     required : true,
            //         //     minlength: 4,
            //         //     remote   : {
            //         //         url : 'index.php?act=seccode&op=check&nchash=<?php echo getNchash();?>',
            //         //         type: 'get',
            //         //         data:{
            //         //             captcha : function(){
            //         //                 return $('#captcha').val();
            //         //             }
            //         //         }
            //         //     }
            //         // }
            //     },
            //     messages : {
            //         username : {
            //             required : '<?php echo $lang['login_usersave_login_usersave_username_isnull'];?>'
            //         },
            //         email  : {
            //             required : '<?php echo $lang['login_password_input_email'];?>',
            //             email : '<?php echo $lang['login_password_wrong_email'];?>'
            //         },
            //         captcha : {
            //             required : '<?php echo $lang['login_usersave_code_isnull']  ;?>',
            //             minlength : '<?php echo $lang['login_usersave_wrong_code'];?>',
            //             remote   : '<?php echo $lang['login_usersave_wrong_code'];?>'
            //         }
            //     }
            // });
        })
    </script>

    <div class="nc-login-layout" style="display: none;">
        <?php
            $img = tpl_get("logo");

        ?>
<!--        <a href="--><?php //echo $img['link'] ?><!--">-->
<!--            <img src="--><?php //echo $img['pic'] ?><!--" alt="" style="width: 160px;height: 100px;float: left;">-->
<!--        </a>-->
        <div style="clear: both;"></div>
        <!--    <div class="left-pic"> <img src="--><?php //echo $output['lpic'];?><!--"  border="0"> </div>-->


        <div class="nc-login" style="margin: 0 auto;float: none;margin-top: 30px;">



            <div class="nc-login-title">
                <h3><?php echo $lang['login_index_find_password'];?></h3>
            </div>
            <div class="nc-login-content" id="demo-form-site">
                <form action="index.php?act=login&op=find_password" method="POST" id="find_password_form">
                    <?php Security::getToken();?>
                    <input type="hidden" name="form_submit" value="ok" />
                    <input name="nchash" type="hidden" value="<?php echo getNchash();?>" />
                    <dl>
                        <dt><?php echo $lang['login_password_you_account'];?></dt>
                        <dd style="min-height:54px;">
                            <input type="text" class="text" name="username"/>
                            <label></label>
                        </dd>
                    </dl>
                    <dl>
                        <dt><?php echo $lang['login_password_you_email'];?></dt>
                        <dd style="min-height:54px;">
                            <input type="text" class="text" name="email"/>
                            <label></label>
                        </dd>
                    </dl>
                    <!-- <dl>
          <dt><?php echo $lang['login_register_code'];?></dt>
          <dd style="min-height:54px;">
            <input type="text" name="captcha" class="text w50 fl" id="captcha" maxlength="4" size="10" />
            <img src="index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>" title="<?php echo $lang['login_index_change_checkcode'];?>" name="codeimage" border="0" id="codeimage" class="fl ml5"> <a href="javascript:void(0);" class="ml5" onclick="javascript:document.getElementById('codeimage').src='index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>&t=' + Math.random();"><?php echo $lang['login_password_change_code']; ?></a>
            <label></label>
          </dd>
        </dl> -->
                    <dl class="mb30" style="">
                        <!--                    <dt></dt>-->
                        <dd style="float: none;width: 100%;text-align: center;margin-top: 30px;">
                            <input type="button" class="submit" value="重置密码" name="Submit" id="Submit">
                        </dd>
                    </dl>
                    <input type="hidden" value="<?php echo $output['ref_url']?>" name="ref_url">
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function(){
            $('#Submit').click(function(){
                if($("#find_password_form").valid()){
                    ajaxpost('find_password_form', '', '', 'onerror');
                } else{
                    document.getElementById('codeimage').src='<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>&t=' + Math.random();
                }
            });
            $('#find_password_form').validate({
                errorPlacement: function(error, element){
                    var error_td = element.parent('dd');
                    error_td.find('label').hide();
                    error_td.append(error);
                },
                rules : {
                    username : {
                        required : true
                    },
                    email : {
                        required : true,
                        email : true
                    }
                    // ,
                    // captcha : {
                    //     required : true,
                    //     minlength: 4,
                    //     remote   : {
                    //         url : 'index.php?act=seccode&op=check&nchash=<?php echo getNchash();?>',
                    //         type: 'get',
                    //         data:{
                    //             captcha : function(){
                    //                 return $('#captcha').val();
                    //             }
                    //         }
                    //     }
                    // }
                },
                messages : {
                    username : {
                        required : '<?php echo $lang['login_usersave_login_usersave_username_isnull'];?>'
                    },
                    email  : {
                        required : '<?php echo $lang['login_password_input_email'];?>',
                        email : '<?php echo $lang['login_password_wrong_email'];?>'
                    },
                    captcha : {
                        required : '<?php echo $lang['login_usersave_code_isnull']	;?>',
                        minlength : '<?php echo $lang['login_usersave_wrong_code'];?>',
                        remote   : '<?php echo $lang['login_usersave_wrong_code'];?>'
                    }
                }
            });
        });
    </script>

    <?php
        include(templet('index','footer'));
    ?>
    <?php exit; ?>


<link href="<?php echo SHOP_TEMPLATES_URL;?>/css/home_login.css" rel="stylesheet" type="text/css">
<style type="text/css">
.public-top-layout, .head-app, .head-search-bar, .head-user-menu, .public-nav-layout, .nch-breadcrumb-layout, #faq {
	display: none !important;
}
.public-head-layout {
	margin: 10px auto -10px auto;
}
.wrapper {
	width: 1000px;
}
#footer {
	border-top: none!important;
	padding-top: 30px;
}
</style>
<div class="nc-login-layout">
  <div class="left-pic"> <img src="<?php echo $output['lpic'];?>"  border="0"> </div>
  <div class="nc-login">
    <div class="nc-login-title">
      <h3><?php echo $lang['login_index_find_password'];?></h3>
    </div>
    <div class="nc-login-content" id="demo-form-site">




      <form action="index.php?act=login&op=find_password" method="POST" id="find_password_form">
        <?php Security::getToken();?>
        <input type="hidden" name="form_submit" value="ok" />
        <input name="nchash" type="hidden" value="<?php echo getNchash();?>" />
        <dl>
          <dt><?php echo $lang['login_password_you_account'];?></dt>
          <dd style="min-height:54px;">
            <input type="text" class="text" name="username"/>
            <label></label>
          </dd>
        </dl>
        <dl>
          <dt><?php echo $lang['login_password_you_email'];?></dt>
          <dd style="min-height:54px;">
            <input type="text" class="text" name="email"/>
            <label></label>
          </dd>
        </dl>
        <!-- <dl>
          <dt><?php echo $lang['login_register_code'];?></dt>
          <dd style="min-height:54px;">
            <input type="text" name="captcha" class="text w50 fl" id="captcha" maxlength="4" size="10" />
            <img src="index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>" title="<?php echo $lang['login_index_change_checkcode'];?>" name="codeimage" border="0" id="codeimage" class="fl ml5"> <a href="javascript:void(0);" class="ml5" onclick="javascript:document.getElementById('codeimage').src='index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>&t=' + Math.random();"><?php echo $lang['login_password_change_code']; ?></a>
            <label></label>
          </dd>
        </dl> -->
        <dl class="mb30">
          <dt></dt>
          <dd>
            <input type="button" class="submit" value="重置密码" name="Submit" id="Submit">
          </dd>
        </dl>
        <input type="hidden" value="<?php echo $output['ref_url']?>" name="ref_url">
      </form>
    </div>
    <div class="nc-login-bottom"></div>
  </div>
</div>
<script type="text/javascript">
$(function(){
    $('#Submit').click(function(){
        if($("#find_password_form").valid()){
        	ajaxpost('find_password_form', '', '', 'onerror');
        } else{
        	document.getElementById('codeimage').src='<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>&t=' + Math.random();
        }
    });
    $('#find_password_form').validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd');
            error_td.find('label').hide();
            error_td.append(error);
        },
        rules : {
            username : {
                required : true
            },
            email : {
                required : true,
                email : true
            }
            // ,
            // captcha : {
            //     required : true,
            //     minlength: 4,
            //     remote   : {
            //         url : 'index.php?act=seccode&op=check&nchash=<?php echo getNchash();?>',
            //         type: 'get',
            //         data:{
            //             captcha : function(){
            //                 return $('#captcha').val();
            //             }
            //         }
            //     }
            // }
        },
        messages : {
            username : {
                required : '<?php echo $lang['login_usersave_login_usersave_username_isnull'];?>'
            },
            email  : {
                required : '<?php echo $lang['login_password_input_email'];?>',
                email : '<?php echo $lang['login_password_wrong_email'];?>'
            },
            captcha : {
                required : '<?php echo $lang['login_usersave_code_isnull']	;?>',
                minlength : '<?php echo $lang['login_usersave_wrong_code'];?>',
                remote   : '<?php echo $lang['login_usersave_wrong_code'];?>'
            }
        }
    });
});
</script>
<?php }?>
